package org.example.chapter1;

import rx.Single;
import rx.SingleSubscriber;

public class Demo1_3_4 {
    public static void main(String[] args) {
        Single.create(new Single.OnSubscribe<Integer>(){

            @Override
            public void call(SingleSubscriber<? super Integer> singleSubscriber) {
                if (!singleSubscriber.isUnsubscribed()) {
                    singleSubscriber.onError(new Throwable("onError"));
                }
            }
        }).subscribe(new SingleSubscriber<Integer>() {
            @Override
            public void onSuccess(Integer integer) {
                System.err.println("onSuccess");
            }

            @Override
            public void onError(Throwable throwable) {
                System.err.println("出错了");
                System.err.println(throwable.getMessage());
            }
        });
    }
}
